/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.uniminuto.edu.videominuto.entities;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Juan
 */
@Entity
@Table(name = "reg_personas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RegPersonas.findAll", query = "SELECT r FROM RegPersonas r"),
    @NamedQuery(name = "RegPersonas.findByIdVideo", query = "SELECT r FROM RegPersonas r WHERE r.regPersonasPK.idVideo = :idVideo"),
    @NamedQuery(name = "RegPersonas.findByIdPersona", query = "SELECT r FROM RegPersonas r WHERE r.regPersonasPK.idPersona = :idPersona"),
    @NamedQuery(name = "RegPersonas.findByIdTipoPersona", query = "SELECT r FROM RegPersonas r WHERE r.regPersonasPK.idTipoPersona = :idTipoPersona")})
public class RegPersonas implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RegPersonasPK regPersonasPK;
    @JoinColumn(name = "id_tipo_persona", referencedColumnName = "id_tipo_persona", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TipoPersona tipoPersona;
    @JoinColumn(name = "id_persona", referencedColumnName = "id_persona", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Persona persona;
    @JoinColumn(name = "id_video", referencedColumnName = "id_video", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Video video;

    public RegPersonas() {
    }

    public RegPersonas(RegPersonasPK regPersonasPK) {
        this.regPersonasPK = regPersonasPK;
    }

    public RegPersonas(int idVideo, int idPersona, int idTipoPersona) {
        this.regPersonasPK = new RegPersonasPK(idVideo, idPersona, idTipoPersona);
    }

    public RegPersonasPK getRegPersonasPK() {
        return regPersonasPK;
    }

    public void setRegPersonasPK(RegPersonasPK regPersonasPK) {
        this.regPersonasPK = regPersonasPK;
    }

    public TipoPersona getTipoPersona() {
        return tipoPersona;
    }

    public void setTipoPersona(TipoPersona tipoPersona) {
        this.tipoPersona = tipoPersona;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    public Video getVideo() {
        return video;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (regPersonasPK != null ? regPersonasPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RegPersonas)) {
            return false;
        }
        RegPersonas other = (RegPersonas) object;
        if ((this.regPersonasPK == null && other.regPersonasPK != null) || (this.regPersonasPK != null && !this.regPersonasPK.equals(other.regPersonasPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.uniminuto.edu.videominuto.entities.RegPersonas[ regPersonasPK=" + regPersonasPK + " ]";
    }
    
}
